package cn.laike.modules.dev.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.Query;

import cn.laike.modules.dev.dao.PrinterDao;
import cn.laike.modules.dev.entity.PrinterEntity;
import cn.laike.modules.dev.service.PrinterService;


@Service("printerService")
public class PrinterServiceImpl extends ServiceImpl<PrinterDao, PrinterEntity> implements PrinterService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	//酒店ID
    	String hotelId = (String)params.get("hotelId");	
        Page<PrinterEntity> page = this.selectPage(
                new Query<PrinterEntity>(params).getPage(),
                new EntityWrapper<PrinterEntity>()
                .eq("hotel_id", hotelId)   
                .orderBy("id", false)
        );

        return new PageUtils(page);
    }

	@Override
	public List<PrinterEntity> queryPrinterList(Integer hotelId) {
		return this.selectList(new EntityWrapper<PrinterEntity>()
                .eq("hotel_id", hotelId)   
                .orderBy("id", false));
	}

	@Override
	public PrinterEntity queryPrinterList(String sn) {
		List<PrinterEntity> list = this.selectList(new EntityWrapper<PrinterEntity>()
                .eq("sn", sn)   
                .orderBy("id", false));
		return (list != null && list.size() >0) ? list.get(0) : null;
	}

}
